 use OlympusSoftware

--drop table [dbo].[GlobalizeSites]
--drop table [dbo].[GlobalizePages]
--drop table [dbo].[GlobalizeLanguages]
--drop table [dbo].[GlobalizeInfoLanguages]

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[GlobalizeSites]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[GlobalizeSites]
GO
CREATE TABLE [dbo].[GlobalizeSites]
(
	[IdSite] [int] NOT NULL,
	[Url] [text],
	[Desc] [text],
	Primary Key (IdSite)
)
GO
 
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[GlobalizePages]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[GlobalizePages]
GO
CREATE TABLE [dbo].[GlobalizePages]
(
	[IdPage] [int] NOT NULL,
	[FK_IdSite] [int] NOT NULL,
	[Filename] [text] NOT NULL,
	[Desc] [nvarchar] (50),
	CONSTRAINT PK_IdPage Primary Key (FK_IdSite, IdPage),
	CONSTRAINT FK_IdSite Foreign Key (FK_IdSite) references [dbo].[GlobalizeSites](IdSite)
)
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[GlobalizeLanguages]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[GlobalizeLanguages]
GO
CREATE TABLE [dbo].[GlobalizeLanguages] (
	[IdLanguage] [int]  NOT NULL ,
	[Lang] [char] (5) NOT NULL,
	Primary Key (IdLanguage)
) 
GO
 
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[GlobalizeInfoLanguages]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[GlobalizeInfoLanguages]
GO
CREATE TABLE [dbo].[GlobalizeInfoLanguages]
(
	[IdInfo] [int] NOT NULL,
	[FK_IdLanguage] [int] NOT NULL,
	[FK_IdPage] [int] NOT NULL,
	[FK_IdSite] [int] NOT NULL,
	[TextInfo] [text],
	Primary Key (IdInfo, FK_IdLanguage, FK_IdPage, FK_IdSite),
	CONSTRAINT FK_IdLanguage Foreign Key (FK_IdLanguage) references [dbo].[GlobalizeLanguages](IdLanguage),
	CONSTRAINT FK_IdPage_IdSite Foreign Key (FK_IdSite, FK_IdPage) references [dbo].[GlobalizePages](FK_IdSite, IdPage)
)
GO

